package ${CreateCommandPackage};

import ${EntityPackage}.${EntityClassName};
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import org.springframework.beans.BeanUtils;
import java.time.LocalDateTime;
/**
 * <p>
 * ${table.comment!}保存命令
 * </p>
 * @author ${author}
 * @since ${date}
 */
@Data
@ApiModel("${table.comment!}保存")
public class ${CreateCommandClassName} {
<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
    <#if field.keyFlag>
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>
   <#if field.propertyName!='id' && field.propertyName!='isEnabled' && field.propertyName!='createdBy' && field.propertyName!='createdTime' && field.propertyName!='updatedBy' && field.propertyName!='updatedTime'&& field.propertyName!='description'>
    /**
    * ${field.comment!field.propertyName}
    */
    @ApiModelProperty(value="${field.comment!field.propertyName}"<#if !field.metaInfo.nullable &&!field.keyFlag>,required = true</#if>)
    <#if !field.keyFlag>
        <#if !field.metaInfo.nullable>
            <#if field.columnType.type=="String">
    @NotBlank(message = "${field.comment!field.propertyName}不能为空")
            <#else>
    @NotNull(message = "${field.comment!field.propertyName}不能为空")
            </#if>
        </#if>
    </#if>
    private ${field.propertyType} ${field.propertyName};

    </#if>
</#list>
<#------------  END 字段循环遍历  ---------->

     public ${EntityClassName} toAggregate(){
         ${EntityClassName} aggregate=new ${EntityClassName}();
         BeanUtils.copyProperties(this,aggregate);
         return aggregate;
     }
}
